<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>工资想过万，键盘要敲烂</title>
    <style></style>
  </head>

  <body>
    <script>
      let str = '今天起的有点早'

      // str = str.replace('今', '<span style="color: red">今</span>')
      // console.log(str)

      // 第一个参数写正则
      // str = str.replace(/今/g, '<span style="color: red">今</span>')

      // document.body.innerHTML = str

      // 把a,c进行高亮
      // let str2 = 'abcabABCc'
      // str2 = str2.replace(/a|c/gi, function (item) {
      //   return `<span style="color: red">${item}</span>`
      // })
      // document.body.innerHTML = str2

      // 把c找到进行大写
      let str3 = 'accdbdc'
      str3 = str3.replace(/c/g, function (i) {
        return `<span>${i}</span>`
      })
      document.body.innerHTML = str3
    </script>
  </body>
</html>
